<?php
session_start();
if (!session_is_registered('user')) exit();

$config = sqlite_open("config.db");
$gen = @sqlite_fetch_array(@sqlite_query($config, "SELECT * FROM general"));
$host = $gen['host'];
$port = $gen['streamport'];
$id = $_GET['id'];
$w = $_GET['w'];
$h = $_GET['h'];


if ($id) {
  $live = sqlite_fetch_array(sqlite_query($config, "SELECT * FROM live WHERE id='$id'"));
  if (($live['admin'] == 1) && (!session_is_registered('admin'))) exit();
  $alias = $live['alias'];
  $w = 640;
  $h = 480;
}
else {
  if (!session_is_registered('admin')) exit();
  $sql = sqlite_query($config, "SELECT * FROM live WHERE name='Screen Capture'");
  if (sqlite_num_rows($sql) > 0) {
    $live = sqlite_fetch_array($sql);
    $alias = $live['alias'];
    $name = $live['name'];
    $w = 595;
    $h = 446;
  }
  else exit();
}
?>

<html>
<head>
<title><?php echo $name;?></title>

<script id="clientEventHandlersJS" language="javascript">
<!--

function OnLoad()
{
    document.UPlayer.UseTCP();
    document.UPlayer.UseMediaServer("<?php echo $host;?>:<?php echo $port;?>");
    document.UPlayer.UseLiveAlias("<?php echo $alias;?>");
    document.UPlayer.EnableFlowControl(false, false);
    document.UPlayer.Play();
}
-->
</script>
</head>
<body onload="OnLoad()">

<OBJECT id="UPlayer"
        width="<?php echo $w;?>"
        height="<?php echo $h;?>"
        classid="clsid:CA11EB7C-1C85-4577-8A49-9E28EFB30184"
        CODEBASE="extra/UMediaControl4.cab">
</OBJECT>
</body>
</html>